Skip to content

feat: add support for OP_RETURN output on the send path - #2753

Draft
dorianvp wants to merge 6 commits into
zingolabs:devfrom
dorianvp:feat/add-opreturn
Draft

feat: add support for OP_RETURN output on the send path#2753
dorianvp wants to merge 6 commits into
zingolabs:devfrom
dorianvp:feat/add-opreturn

Conversation

@dorianvp

@dorianvp dorianvp commented Aug 31, 2026

Copy link
Copy Markdown
Member

Adds an optional OP_RETURN (null-data) output to the send path by keeping zcash_client_backend for planning and bypassing create_proposed_transactions only for the payload-carrying transaction.

@dorianvp dorianvp changed the title SKETCH: minimal OP_RETURN seam over the existing zcb spend path (alt to #2469) feat: add support for OP_RETURN output on the send path Aug 31, 2026
Adds an optional OP_RETURN (null-data) output to the send path.

`zcash_client_backend` still plans and, for payload-free sends, builds the
whole proposal. When a payload is present it rides the final transaction
of the proposal (the ZIP-320 TEX exposure step, or the single step
otherwise), which is built by driving the `zcash_primitives` transaction
builder directly so `add_transparent_null_data_output` can be called; a
Shield never carries a payload.

Adds a validated `OpReturnData` newtype (<=80 bytes) with a typed error,
and threads `Option<OpReturnData>` through `calculate_transactions`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
dorianvp and others added 5 commits September 3, 2026 16:22
Replaces the sketch stub with a working THORChain / MAYAChain swap-deposit
flow. `LightClient::propose_swap_deposit(vault, amount, memo, account)`
sends two transactions, the same shape as a ZIP-320 TEX pair:

1. a deshield from shielded funds to a freshly reserved, wallet-owned
   transparent address, built entirely by zcash_client_backend, and
2. a transparent memo carrier spending that output to the vault with the
   swap memo in an 80-byte OP_RETURN, hand-built on the zcash_primitives
   builder (the only place OP_RETURN support exists upstream).

The deshield funds the carrier exactly, so the carrier has no change and
always balances; its transparent input is the refundable sender THORChain
/ MAYAChain require. Only the transparent carrier is hand-built; the
shielded spend stays in zcb, and all consensus-critical pieces (builder,
ZIP-317 fee, prover, persistence) are reused from upstream.

New: wallet/op_return.rs (validated OpReturnData newtype), wallet/swap.rs
(fee sizing, carrier build/persist, deshield-output location), the
propose_swap_deposit orchestration, and typed errors.

Tests: 9 offline unit tests plus a passing regtest integration test
(swap_deposit_carries_op_return_to_vault_on_chain) proving both
transactions confirm on-chain with the memo in the carrier's OP_RETURN.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Removes explanatory inline comments from the OP_RETURN swap-deposit code
and its tests, leaving the doc comments. No behavior change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant